home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 31
/
Aminet 31 (1999)(Schatztruhe)[!][Jun 1999].iso
/
Aminet
/
dev
/
gui
/
gui4cli.lha
/
Gui4Cli
/
Dir
/
dir.gfxcon
< prev
next >
Wrap
Text File
|
1999-04-21
|
6KB
|
321 lines
G4C
; dir.gfxcon - by dck January 1997
; A GUI for the great picture format converter :
; GfxCon V1.7 © Dirk Farin / farindk@trick.informatik.uni-stuttgart.de
; (Available on Aminet)
; Looks for GFXcon under the name contained in variable $DEF.GFXCON
WINBIG 180 15 200 166 "GfxCon V1.7"
WinType 11110001
xOnLoad
ifexists file $*DEF.GFXCON ; you MUST have configured dir.gc
; You're my kind of guy..
else
EZReq "GFXcon not found!\nPlease configure\nDir.gc correctly." "OK" ""
guiquit dir.gfxcon
stop
endif
format = ILBM ; our variables
colors = ""
bw = ""
flip = ""
rot = ""
x = 320
y = 250
size = ""
file = ""
mode = FILES
gosub dir.gfxcon FileMode
guiopen dir.gfxcon
xOnClose
delvar #?
guiquit dir.gfxcon
xRoutine FileMode
setgad dir.gfxcon 1/13 HIDE
setgad dir.gfxcon 21/25 SHOW
redraw dir.gfxcon
xRoutine ConvertMode
setgad dir.gfxcon 1/13 SHOW
setgad dir.gfxcon 21/25 HIDE
redraw dir.gfxcon
XCYCLER 0 0 200 14 "" mode
cstr "Choose/Add Files" FILES
Cstr "Converting Options" CONVERT
if $mode = CONVERT
gosub dir.gfxcon ConvertMode
else
gosub dir.gfxcon FileMode
endif
;------------------------------- PRETTY OBVIOUS OPTIONS GADGETS
XCYCLER 70 15 125 14 Format format
GadID 1
cstr ILBM ILBM
cstr GIF GIF
cstr JPEG JPEG
cstr PCX PCX
cstr PostScript Postscript
cstr RGB-Raw RGB-Raw
XCYCLER 70 30 125 14 Colors colors
GadId 2
cstr Default ""
cstr 16 16
cstr 32 32
cstr 128 128
cstr 256 256
cstr 2 2
cstr 4 4
cstr 8 8
XCYCLER 70 45 125 14 Type bw
GadId 3
cstr Default ""
cstr GRAYSCALE GRAYSCALE
cstr BW BW
cstr INVERT INVERS
cstr "NO Red" NORED
cstr "NO Green" NOGREEN
cstr "NO Blue" NOBLUE
XCYCLER 70 60 125 14 Flip flip
gadid 11
Cstr None ""
cstr "Flip X" FLIPX
cstr "Filp Y" FLIPY
cstr "Flip XY" "FLIPX FLIPY"
XCYCLER 70 75 125 14 Rotate rot
gadid 12
cstr None ""
cstr "90 Left" ROTATELEFT
cstr "90 Right" ROTATERIGHT
; NOT IMPLEMENTED YET
; slider contrast CONTRAST 0-100
; slider brightness BRIGHTNESS 0-255
;---- Size
XCYCLER 70 90 125 14 Size size
gadid 4
cstr Same ""
cstr BOXFIT BOXFIT
cstr SIZE SIZE
if $size = NONE
setgad dir.gfxcon 5 OFF
setgad dir.gfxcon 6 OFF
else
setgad dir.gfxcon 5 ON
setgad dir.gfxcon 6 ON
endif
; -- Size textin gadgets
XTEXTIN 70 105 61 14 "" x 320 10
gadid 5
SetGad dir.gfxcon 6 ON
XTEXTIN 135 105 59 14 "" y 250 10
gadid 6
; -------------------- Status Boxes
TEXT 5 112 40 10 "Status:" 20 NOBOX
gadid 7
TEXT 4 123 190 12 "No Files" 130 BOX
GadID 8
Gauge 4 136 190 12 IN BUTTON 3 0 0
gadid 13
xPIPE pipe:gfxcon ON
if $mode = CONVERT
and $finishflag = 0
update dir.gfxcon 8 '$$PIPE'
endif
;--------------------- LISTVIEW SHOWING FILES TO CONVERT
XLISTVIEW 0 15 198 132 "" file "" 10 MULTI
gadid 21
XBUTTON 0 150 50 14 View
gadid 25
lvuse dir.gfxcon 21
lvmulti first
while $file > ""
*RUNMODE = 'run >nil:'
*FILENAME = $file
gosub viewfile.g ViewFile
lvmulti next
endwhile
XBUTTON 50 150 50 14 Add ; add files selected from dir.gc
gadid 22
id = $$lv.id
lvuse dir.gc $id
lvmulti first
while $dir.gc/lv_file > ""
lvuse dir.gfxcon 21
lvadd $dir.gc/lv_file
lvuse dir.gc $id
lvmulti off
lvmulti next
endwhile
XBUTTON 100 150 50 14 Del ; delete selected files
gadid 23
lvuse dir.gfxcon 21
lvmulti first
while $file > ""
lvdel -1
lvmulti first ; use first again since last first was deleted
endwhile
XBUTTON 150 150 50 14 Clr
gadid 24
lvuse dir.gfxcon 21
lvclear
;-------------------- Cancel the relaunch of gfxcon
XBUTTON 100 150 95 14 CANCEL
gadfont topaz.font 8 010
gadid 9
flag = 1
;-------------------- This is where we do our stuff!
XBUTTON 5 150 95 14 "Convert"
gadid 10
gadfont topaz.font 8 010
flag = 0
finishflag = 0
lvuse dir.gfxcon 21
count = 0
total = $$lv.tot
update dir.gfxcon 13 0 ; gauge
lvgo #0
cfile = $$lv.rec
if $cfile > ""
gosub dir.gfxcon addextension
lvdel 0
update dir.gfxcon 7 Converting:
update dir.gfxcon 8 $cfile
gosub dir.gfxcon makecom
setstack 20000
; say '$*DEF.GFXCON >pipe:gfxcon $cfile $com \n'
Launch 1 '$*DEF.GFXCON >pipe:gfxcon $cfile $com NOPROGRESS'
setstack 4000
endif
; This is where the Launch command will return to when the program
; it has run has finished executing. We then tell it to do it again
xOnReturn 1
if $mode = CONVERT
update dir.gfxcon 13 0
update dir.gfxcon 7 Status:
update dir.gfxcon 8 Finished
endif
if $flag = 1
stop
endif
lvuse dir.gfxcon 21
lvgo #0
cfile = $$lv.rec
if $cfile > ""
++count
temp == $count * 100
ratio == $temp / $total
update dir.gfxcon 13 $ratio ; gauge
gosub dir.gfxcon addextension
lvdel 0
update dir.gfxcon 7 Converting:
update dir.gfxcon 8 $cfile
gosub dir.gfxcon makecom
setstack 20000
; say '$*DEF.GFXCON >pipe:gfxcon $cfile $com \n'
Launch 1 '$*DEF.GFXCON >pipe:gfxcon $cfile $com NOPROGRESS'
setstack 4000
else
update dir.gfxcon 8 "Finished."
finishflag = 1
endif
; ------------ Routine to form command line
xroutine makecom
com = 'FORMAT $format'
if $colors > ""
appvar com ' COLORS $colors'
endif
if $bw > ""
appvar com ' $bw'
endif
if $flip > ""
appvar com ' $flip'
endif
if $rot > ""
appvar com ' $rot'
endif
if $size > ""
appvar com ' $size $x $y'
endif
xROUTINE addextension
; if file doesn't have an extension, we must add one
extract cfile ext ex
if $ex > ""
return
else
oldname = $cfile
; find out extension according to file type
if $cfile H= "FORM????ILBM"
or $cfile H= "FORM??ILBM"
exname = .iff
elseif $cfile H= GIF
exname = .gif
elseif $cfile H= "??????JFIF"
or $cfile H= "ÿØÿÄ"
exname = .jpg
else ; we don't know what it is
exname = .ext
endif
; handle possible quoted string
if $cfile[-1][1] = '"'
cutvar cfile cut char -1 ''
appvar cfile '$exname\"'
else
appvar cfile '$exname'
endif
rename $oldname $cfile
endif
; --------------
; This is where we'll end up if anything goes wrong..
; i.e. such as GFXcon not finding the file and returning an error status
xOnFail
EZReq "An error occured.\nClick on Convert to continue." "OK" ""
RESIZE_BIG 180 15 257 187 DIR.GFXCON